home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / rpc_chk.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1998-07-17  |  2KB  |  78 lines

  1. #!/bin/sh
  2. #rpc.chk 1.0
  3. #
  4. # Make sure you have got a newer version of Bourne Shell (SVR2 or newer)
  5. # that supports functions. It's usually located in /bin/sh5 (under ULTRIX OS)
  6. # or /bin/sh (Sun OS, RS/6000 etc) If it's located elsewhere, feel free to
  7. # change the magic number, indicating the type of executable Bourne Shell.
  8. #
  9. # The script obtains via nslookup utility a list of hostnames from a nameserver
  10. # and checks every entry of the list for active rexd procedures as well as
  11. # ypserver procedures. The output is a list of the sites that run those
  12. # daemons and are insecure.
  13. #  -yo.
  14.  
  15.  
  16. domainname=$1
  17. umask 022
  18. PATH=/bin:/usr/bin:/usr/ucb:/usr/etc:/usr/local/bin ; export PATH
  19.  
  20. #
  21. # Function collects a list of sites
  22. # from a nameserver. Make sure you've got the nslookup utility.
  23. #
  24. get_list() {
  25. (
  26. echo set type=ns
  27. echo $domainname
  28. ) | nslookup | egrep "nameserv" | cut -d= -f2> .tmp$$  2>/dev/null
  29. if [ ! -s .tmp$$ ]; then
  30. echo "No such domain" >&2
  31. echo "Nothing to scan" >&2
  32. exit 1
  33. fi
  34. for serv in `cat .tmp$$`;do
  35. (
  36. echo server $serv
  37. echo ls  $domainname
  38. ) | nslookup > .file$$ 2>/dev/null
  39. lines=`cat .file$$ | wc -l`
  40. tail -`expr $lines  - 7` .file$$  | cut -d" " -f2 > .file.tmp # .file
  41. sed -e "s/$/.$domainname/"  .file.tmp > .hosts$$
  42. rm -rf .file* .tmp$$
  43. sort .hosts$$ | uniq -q >> HOSTS$$; rm -rf .hosts$$
  44. done
  45. tr 'A-Z' 'a-z' <HOSTS$$ |sort|uniq -q > HOSTS.$domainname;rm -rf HOSTS$$
  46. }
  47.  
  48. # Function
  49.  
  50. rpc_calls()
  51. {
  52. for entry in `cat HOSTS.$domainname`; do
  53. (
  54. rpcinfo -t $entry ypserv >/dev/null  && echo $entry runs YPSERV ||  exit 1 # Error!
  55. ) >> .log  2>/dev/null
  56. (
  57. rpcinfo -t $entry rex >/dev/null && echo $entry runs REXD ||  exit 1 # Error !
  58.  ) >> .log  2>/dev/null
  59. done
  60. }
  61.  
  62. # Main
  63.  
  64. if [ "$domainname" = '' ];  then
  65. echo "Usage $0 domainname" >&2
  66. exit 1
  67. fi
  68. get_list
  69. echo "Checking $domainname domain" > .log
  70. echo "*****************************" >> .log
  71. echo "Totally `cat HOSTS.$domainname | wc -l` sites  to scan" >> .log
  72. echo "******************************" >> .log
  73. echo "started at `date`" >> .log
  74. echo "******************************" >> .log
  75. rpc_calls
  76. echo "******************************" >> .log
  77. echo "finished at `date`"  >> .log
  78.